class Solution {
    public int maxProfit(int[] prices) {
        if(prices.length<=1){
            return 0;
        }
        int buy = 0;
        int max = 0;
        for(int i = 0;i<prices.length-1;i++){
            for(int j = i+1;j<prices.length;j++){
                buy = prices[j] - prices[i];
                if(buy>=max){
                    max = buy;
                }
            }
        }
        return max;
    }
}